
	<div id="customerSelDlg" class="easyui-dialog"
		title="Select Customer..."
		style="width: 400px; height: 300px; padding: 10px"
		data-options="toolbar: '#customerSel-toolbar',
			buttons: '#customerSel-buttons',
			closed: true">
		<ul id="customerSelTree" class="easyui-tree"></ul>
	</div>
	<div id="addNewCustomerDlg" class="easyui-dialog"
		title="Add New Customer..."
		style="width: 400px; height: 200px; padding: 10px"
		data-options="buttons: '#addCustomer-buttons',
			closed: true">
		<table>
			<tr>
				<td>Parent:</td>
				<td><input class="easyui-combotree" id="newParentId"
					style="width: 200px;"></td>
			</tr>
			<tr>
				<td>Customer Id:</td>
				<td><input class="easyui-validatebox" type="text"
					name="newCustomerId" id="newCustomerId" style="width: 100px;"
					maxlength="20" data-options="required:true"></input></td>
			</tr>
			<tr>
				<td>Customer Name:</td>
				<td><input class="easyui-validatebox" type="text"
					name="newCustomerName" id="newCustomerName" style="width: 250px;"
					data-options="required:true"></input></td>
			</tr>
		</table>
	</div>

	<div id="customerSel-toolbar" style="padding: 2px 0">
		<table cellpadding="0" cellspacing="0" style="width: 100%">
			<tr>
				<td style="padding-left: 2px"><a id="addCustomer"
					href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-add',plain:true">Add New</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-help',plain:true">Help</a></td>
			</tr>
		</table>
	</div>

	<script type="text/javascript">
		function addNewCustomer() {
			$.getJSON('loadProjectCode.htm?code=Customer', function(data) {
				$("#customerSelDlg").dialog("close");
				$("#newParentId").combotree('loadData', data);
				$("#addNewCustomerDlg").dialog("open");
			});
		}

		function selectValue() {
			var node = $('#customerSelTree').tree('getSelected');
			if (node) {
				$("#customer").val(node.text);
				$("#hidcustomer").val(node.id);
				$('#customerSelDlg').dialog('close');
				enableDisableValidation('customer','hidcustomer');
			}
		}
		function selectCustomer() {
			$.getJSON("loadProjectCode.htm?code=Customer", function(data) {
				$("#customerSelTree").tree('loadData', data);
			});
			$('#customerSelDlg').dialog('open');
		}
		
		function saveNewCustomer() {
			var node = $("#newParentId").combotree('tree').tree('getSelected');
			var parentId = node ? node.id : "";
			var data = {
				"parentId" : parentId,
				"id" : $("#newCustomerId").val(),
				"name" : $("#newCustomerName").val()
			};
			$.postJSON("addNewCustomer.htm", data, function(result) {
				if (result.success) {
					$("#customer").val(result.text);
					$("#hidcustomer").val(result.id);					
					$("#addNewCustomerDlg").dialog("close");
					enableDisableValidation('customer','hidcustomer');
				} else {
					showMessager("Exception", result.message);
				}
			}, function(xhr, ajaxOptions, thrownError) {
				showMessager("Exception", thrownError);
			});

		}
		function showMessager(title, message) {
			$.messager.show({
				title : title,
				msg : message,
				showType : 'show'
			});
		}
		$("#addCustomer").click(addNewCustomer);
		$("#customerSel").click(selectCustomer);
		
	</script>
	<div id="customerSel-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			onclick="selectValue()">Select</a> <a href="javascript:void(0)"
			class="easyui-linkbutton"
			onclick="javascript:$('#customerSelDlg').dialog('close')">Close</a>
	</div>

	<div id="addCustomer-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			id="saveNewCustomerBtn" onclick="saveNewCustomer();">Save</a> <a href="javascript:void(0)"
			class="easyui-linkbutton"
			onclick="javascript:$('#addNewCustomerDlg').dialog('close')">Close</a>
	</div>
